*******************************************************************************
*** Description: 	This document provides the code for reproducing the 	***
***					figures in Study 1 of the paper, "Compulsory Voting 	***
***					Diminishes the Relationship Between Winning and 		***
***					Satisfaction with Democracy," which is authored by 		***
***					Shane P. Singh and appears in the Journal of Politics	***
***					 														***
***					It also provides the code for reproducing the tables 	***
***					and figures associated with Study 1 in the 				***
***					Supplementary Material.									***
***					 														***
***					It also provides the code for reproducing statistics 	***
***					associated with claims related to Study 1 made in the  	***
***					text.													***
*******************************************************************************


**************
**************
*Set the Version                                                                                                                                 
**************
**************
version 17.0


**************
**************
*Install Required Package (remove initial asterisk if package not yet installed)                                                                                                                     
**************
**************
*ssc install coefplot 


**************
**************
*Open the Required Dataset
**************
**************
use "Argentina_2019_JOP_Replication.dta", clear


**************
**************
*Create Winner (Fernandez) Voting and Valid Voting Variables
**************
**************
gen voted_Fernandez = 1 if vote_prez == 1 
replace voted_Fernandez = 0 if vote_prez ~=1
replace voted_Fernandez = . if vote_prez == .
label var voted_Fernandez "1 if voted winner (Fernandez); 0 otherwise"

 
gen valid_vote = 0 
replace valid_vote = 1 if voted_blank_null == 1
replace valid_vote = . if voted_blank_null == 99
replace valid_vote = . if voted_blank_null == .
label var valid_vote "1 if valid ballot; 0 otherwise"



**************
**************
*Figure 1
**************
**************
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(xb) post level(90) 
coefplot ///
		( , offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Latent Satisfaction with Democracy" " ") ///
	legend(off) 	///			 
	coeflabels( 1._at  = 	`" "Just under 18" "(No Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 18" "(Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-0.5(0.5)3.0)  yscale(range(-.505 3.05)) ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(4.8)  ysize(7) scale(1.31) level(90) format(%9.1f) 


**************
**************
*Evidence for Claim Made in the Text: "The two-sided p-value of the difference in the impact of winning on satisfaction across those subject to and free from mandatory voting is 0.039"
**************
**************		
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  at(days_over_18_election=0 age_18_or_over_election=(0 1) voted_Fernandez = (0 1)) predict(xb) post level(90) coeflegend
test (_b[2._at] - _b[1bn._at]) = (_b[4._at] - _b[3._at]) //*same as p-value on the interaction between winning and exposure to compulsory voting

	
	
**************
**************
*Figure 2
**************
**************	
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(1)) post level(90) 
estimates store cat_1

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(2)) post level(90) 
estimates store cat_2

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(3)) post level(90) 
estimates store cat_3

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(4)) post level(90) 
estimates store cat_4


coefplot ///
		(cat_1, offset(-.15) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
		(cat_2, offset(-.05) recast(scatter) mcolor(red) msize(medsmall) ciopts(lpattern(solid) lcolor(red))) ///
		(cat_3, offset( .05) recast(scatter) mcolor(blue) msize(medsmall) ciopts(lpattern(solid) lcolor(blue))) ///
		(cat_4, offset( .15) recast(scatter) mcolor(green) msize(medsmall) ciopts(lpattern(solid) lcolor(green))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Pr(in Satisfaction Category)" " ") ///
	legend(order(						///
			1 "Very Dissatisfied"  	///
			3 "Dissatisfied" 		///
			5 "Satisfied"		///
			7 "Very Satisfied") 		///
				rows(2) size(vsmall)) 	///			 
	coeflabels( 1._at  = 	`" "Just under 18" "(No Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 18" "(Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-.4(0.2)0.4)  yscale(range(-.46 .46)) ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(6.2)  ysize(8) scale(1.05) level(90) format(%9.1f)	
	
	

**************
**************
*Evidence for Claim Made in the Text: "... a winner who was not compelled to vote is about 31 percentage points more likely to report being "satisfied" than a non-compelled voter who selected a losing candidate. Among those who are compelled to vote, the impact of winning on the probability of being "satisfied" is markedly smaller, at about 7 percentage points, and the difference between these associations has a two-sided p-value of 0.040."
**************
**************		
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(3)) post level(90) 
test _b[1.voted_Fernandez:1bn._at] = _b[1.voted_Fernandez:2._at]

*Evidence for Claim Made in the Text: "... a winner who is was not compelled to vote is about 25 percentage points less likely to report being " dissatisfied" than a non-compelled voter who selected a losing candidate. Among those for whom voting was obligatory, this association is only about 3 percentage points, and the two-sided p-value of the di↵erence between the associations is 0.007."
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(outcome(2)) post level(90) 
test _b[1.voted_Fernandez:1bn._at] = _b[1.voted_Fernandez:2._at]


	
**************
**************
*Figure 3
**************
**************
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(xb) post level(90) 
coefplot ///
		(, offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Latent Satisfaction with Democracy" " ") ///
	legend(off) 	///			 
	coeflabels( 1._at  = 	`" "Just under 70" "(Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 70" "(No Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-0.5(0.5)3.0)  yscale(range(-.505 3.05)) ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(4.8)  ysize(7) scale(1.31) level(90) format(%9.1f) 


**************
**************
*Evidence for Claim Made in the Text: "... the difference in the impact of winning across the two groups does not meet conventional levels of statistical significance (two-sided p = 0.432)."
**************
**************		
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  at(days_over_70_election=0 age_70_or_over=(0 1) voted_Fernandez = (0 1)) predict(xb) post level(90) coeflegend
test (_b[2._at] - _b[1bn._at]) = (_b[4._at] - _b[3._at]) //*same as p-value on the interaction between winning and exposure to compulsory voting


	
**************
**************
*Figure 4
**************
**************
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(outcome(1)) post level(90) 
estimates store cat_1

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(outcome(2)) post level(90) 
estimates store cat_2

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(outcome(3)) post level(90) 
estimates store cat_3

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(outcome(4)) post level(90) 
estimates store cat_4


coefplot ///
		(cat_1, offset(-.15) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
		(cat_2, offset(-.05) recast(scatter) mcolor(red) msize(medsmall) ciopts(lpattern(solid) lcolor(red))) ///
		(cat_3, offset( .05) recast(scatter) mcolor(blue) msize(medsmall) ciopts(lpattern(solid) lcolor(blue))) ///
		(cat_4, offset( .15) recast(scatter) mcolor(green) msize(medsmall) ciopts(lpattern(solid) lcolor(green))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Pr(in Satisfaction Category)" " ") ///
	legend(order(						///
			1 "Very Dissatisfied"  	///
			3 "Dissatisfied" 		///
			5 "Satisfied"		///
			7 "Very Satisfied") 		///
				rows(2) size(vsmall)) 	///			 
	coeflabels( 1._at  = 	`" "Just under 70" "(No Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 70" "(Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-.4(0.2)0.4)  yscale(range(-.46 .46)) ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(6.2)  ysize(8) scale(1.05) level(90) format(%9.1f)	
	
	
**************
**************
*Evidence for Claim Made in the Text: "A winner who was not compelled to vote is about 29 percentage points more likely to report being "satisfied" than a non-compelled voter who selected a losing candidate. Among those who are compelled to vote, the impact of winning on the probability of being "satisfied" is smaller, at about 18 percentage points. Still, the difference in the impact of winning across the two groups does not meet conventional levels of statistical significance (two-sided p = 0.434)."
**************
**************		
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over=(0 1)) predict(outcome(3)) post level(90) 
test _b[1.voted_Fernandez:1bn._at] = _b[1.voted_Fernandez:2._at]



**************
**************
*Table SM1
**************
**************
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust


**************
**************
*Table SM2
**************
**************
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust



**************
**************
*Figure SM1
**************
**************
logit valid_vote  i.age_18_or_over_election##c.days_over_18_election, robust
margins, dydx(age_18_or_over_election) at(days_over_18_election=0) post level(90) 
estimates store valid_18

logit valid_vote  i.age_70_or_over_election##c.days_over_70_election,  robust
margins, dydx(age_70_or_over) at(days_over_70_election=0) post level(90) 
lincomest - _b[1.age_70_or_over] //*reverse the sign so it's the impact of compulsory voting
estimates store valid_70

coefplot ///
		(valid_18, offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
		(valid_70, offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
	,  scheme(s1color) vertical ///
	ytitle("Effect of Being Compelled to Vote" "on Pr(Cast a Valid Vote)") ///
	legend(off) ///
	xlabel(	1	`" "Effect of Being" "Just over 18" "'  ///
			2	`" "Effect of Being" "Just under 70" "'  ///
			, labsize(small)) /// 
	graphregion(margin(small)) ///
	ylabel(0(0.1)0.2)  yscale(range(-.005 .22)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(4)  ysize(8) scale(1.45) level(90) format(%9.1f)


**************
**************
*Evidence for Claim Made in the Text: "... as compared to an average individual just under age 18, who is not required to vote, someone aged just above 18 on election day, who is subject to compulsory voting, is about 12 percentage points more likely to cast a valid ballot (two-sided p = 0.020)."
**************
**************	
logit valid_vote  i.age_18_or_over_election##c.days_over_18_election, robust
margins, dydx(age_18_or_over_election) at(days_over_18_election=0) post level(90) 

**************
**************
*Evidence for Claim Made in the Text: "... as compared to an average individual just over age 70, who is not required to vote, someone aged just below 70 on election day, who is subject to compulsory voting, is about 14 percentage points more likely to cast a valid ballot (two-sided p = 0.004)."
**************
**************	
logit valid_vote  i.age_70_or_over_election##c.days_over_70_election,  robust
margins, dydx(age_70_or_over) at(days_over_70_election=0) post level(90) 



**************
**************
*Figure SM2
**************
**************
*rescale covariates to range between 0 and 1
sum educ 			
gen educ_01 = ((educ - r(min))/(r(max) - r(min))) 

sum income	
gen income_01 = ((income - r(min))/(r(max) - r(min))) 

sum ideo 			
gen ideo_01 = ((ideo - r(min))/(r(max) - r(min)))



*create a series of copies of the age_18_or_over_election variable for coefplot labeling purposes
gen age_18_or_over_election_female =  age_18_or_over_election
gen age_18_or_over_election_educ =  age_18_or_over_election
gen age_18_or_over_election_income =  age_18_or_over_election
gen age_18_or_over_election_ideo =  age_18_or_over_election


*estimate and save imbalances
reg educ_01 i.age_18_or_over_election_educ##c.days_over_18_election  
margins,  dydx(age_18_or_over_election_educ)  at(days_over_18_election = (0)) post
estimates store educ_01_18

reg income_01 i.age_18_or_over_election_income##c.days_over_18_election   
margins,  dydx(age_18_or_over_election_income)  at(days_over_18_election = (0)) post
estimates store income_01_18

reg female i.age_18_or_over_election_female##c.days_over_18_election  
margins,  dydx(age_18_or_over_election_female) at(days_over_18_election = (0)) post
estimates store female_18

reg ideo_01 i.age_18_or_over_election_ideo##c.days_over_18_election   
margins,  dydx(age_18_or_over_election_ideo)  at(days_over_18_election = (0)) post
estimates store ideo_01_18


*create a plot of the differences
coefplot 	///
			(educ_01_18,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
			(income_01_18,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///	
			(female_18,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
			(ideo_01_18,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
		, scheme(s1color)  title("") 	///
		xline(0, lcolor(gs8) lpattern(dash))  ylabel( , labsize(medsmall))  xlabel(-.2(.1).2)  ///
		legend(off) ysize(1.5) scale(1.5) levels(90) format(%9.1f)	///
		xtitle("Estimated Effect of Being Just Over Age 18 on Election Day" "on Mean Value of Covariate", size(medium))  ytitle("") 	///
		coeflabels(	1.age_18_or_over_election_female  = 		"Female"   ///
					1.age_18_or_over_election_educ  = 			"Education"   ///
					1.age_18_or_over_election_income  = 		"Income"   ///
					1.age_18_or_over_election_ideo  = 			"Ideology"   ///
					) name(age_18_balance, replace)  graphregion(margin(small)) ///
					grid(nogextend)




*create a series of copies of the age_70_or_over_election variable for coefplot labeling purposes
gen age_70_or_over_election_female =  age_70_or_over_election
gen age_70_or_over_election_educ =  age_70_or_over_election
gen age_70_or_over_election_income =  age_70_or_over_election
gen age_70_or_over_election_ideo =  age_70_or_over_election


*estimate and save imbalances
reg educ_01 i.age_70_or_over_election_educ##c.days_over_70_election  
margins,  dydx(age_70_or_over_election_educ)  at(days_over_70_election = (0)) post
estimates store educ_01_70

reg  income_01 i.age_70_or_over_election_income##c.days_over_70_election  
margins,  dydx(age_70_or_over_election_income)  at(days_over_70_election = (0)) post
estimates store income_01_70

reg female i.age_70_or_over_election_female##c.days_over_70_election  
margins,  dydx(age_70_or_over_election_female) at(days_over_70_election = (0)) post
estimates store female_70

reg ideo_01 i.age_70_or_over_election_ideo##c.days_over_70_election  
margins,  dydx(age_70_or_over_election_ideo)  at(days_over_70_election = (0)) post
estimates store ideo_01_70


*create a plot of the differences
coefplot 	///
			(educ_01_70,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
			(income_01_70,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///
			(female_70,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
			(ideo_01_70,  offset(0) msymbol(circle) msize(medlarge)  mcolor(black) ciopts(color(black) lwidth(medium))) ///			
		, scheme(s1color)  title("")	///
		xline(0, lcolor(gs8) lpattern(dash))  ylabel( , labsize(medsmall))  xlabel(-.2(.1).2)  ///
		legend(off) ysize(1.5) scale(1.5) levels(90) format(%9.1f)	///
		xtitle("Estimated Effect of Being Just Over Age 70 on Election Day" "on Mean Value of Covariate", size(medium))  ytitle("") 	///
		coeflabels(	1.age_70_or_over_election_female  = 		"Female"   ///
					1.age_70_or_over_election_educ  = 			"Education"   ///
					1.age_70_or_over_election_income  = 		"Income"   ///
					1.age_70_or_over_election_ideo  = 			"Ideology"   ///
					) name(age_70_balance, replace)  graphregion(margin(small)) ///
					grid(nogextend)
					
	
*combine the plots for the younger and older groups
graph combine ///
	age_18_balance ///
	age_70_balance ///
	,   scheme(s1color)  rows(2)  graphregion(margin(zero)) iscale(.7) xsize(10) imargin(1 1 5 5)
	
				




**************
**************
*Figure SM3
**************
**************
postfile bandwidth bandwidth_size b se n_obs using "bandwidth.dta", replace

forvalues days_counter = 100(3)730 {	
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez   educ income female ideo if samp_18 == 1 &  abs(days_over_18_election) <= `days_counter' , robust 
	scalar b =  _b[1.age_18_or_over_election#1.voted_Fernandez]
	scalar se = _se[1.age_18_or_over_election#1.voted_Fernandez]
	scalar n_obs = e(N)
	scalar bandwidth_size = `days_counter'
	post bandwidth (bandwidth_size) (b) (se) (n_obs)
}

postclose bandwidth


preserve

use "bandwidth.dta", clear
gen b_high = b + 1.65*se // Calculate 90% confidence intervals
gen b_low = b - 1.65*se

twoway (line b bandwidth_size, lcolor(black)) ///
	(line b_high bandwidth_size, lpattern(solid) lcolor(gs11) lwidth(thin)) ///
	(line b_low bandwidth_size, lpattern(solid) lcolor(gs11) lwidth(thin)) ///
	(spike n_obs bandwidth_size, yaxis(2)), ///
	xlabel(100(100)700, labsize(small))  legend(off) title() ///
	ylabel(-10(5)10, labsize(small)) ///
	yscale(range(0 4000) axis(2)) ylabel(0(550)550, labsize(small) axis(2)) yline(0, lcolor(gs1) lpattern(dash)) ytitle("Number of Observations                                                                                                                      ", size(vsmall) axis(2)) ///
	xtitle("Bandwidth", size(small)) ytitle("Estimated Effect of Being Over 18 (Compulsory Voting) on" "Association Between Winning and Latent Satisfaction with Democracy", size(small)) graphregion(color(white)) ///
	scheme(s1mono) ysize(5)	
	
restore


**************
**************
*Figure SM4
**************
**************
cd "/Users/singh/Desktop"
postfile bandwidth bandwidth_size b se n_obs using "bandwidth.dta", replace

forvalues days_counter = 100(4)1096 {	
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez   educ income female ideo if samp_70 == 1 &  abs(days_over_70_election) <= `days_counter' , robust 
	scalar b =  _b[1.age_70_or_over_election#1.voted_Fernandez]
	scalar se = _se[1.age_70_or_over_election#1.voted_Fernandez]
	scalar n_obs = e(N)
	scalar bandwidth_size = `days_counter'
	post bandwidth (bandwidth_size) (b) (se) (n_obs)
}

postclose bandwidth


preserve

use "bandwidth.dta", clear
gen b_high = b + 1.65*se // Calculate 90% confidence intervals
gen b_low = b - 1.65*se

twoway (line b bandwidth_size, lcolor(black)) ///
	(line b_high bandwidth_size, lpattern(solid) lcolor(gs11) lwidth(thin)) ///
	(line b_low bandwidth_size, lpattern(solid) lcolor(gs11) lwidth(thin)) ///
	(spike n_obs bandwidth_size, yaxis(2)), ///
	xlabel(100(100)1100, labsize(small))  legend(off) title() ///
	ylabel(-10(5)10, labsize(small)) ///
	yscale(range(0 4000) axis(2)) ylabel(0(550)550, labsize(small) axis(2)) yline(0, lcolor(gs1) lpattern(dash)) ytitle("Number of Observations                                                                                                                      ", size(vsmall) axis(2)) ///
	xtitle("Bandwidth", size(small)) ytitle("Estimated Effect of Being Over 70 (No Compulsory Voting) on" "Association Between Winning and Latent Satisfaction with Democracy", size(small)) graphregion(color(white)) ///
	scheme(s1mono) ysize(5)	
	
restore



**************
**************
*Figure SM5
**************
**************
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=(-731(5)-1) age_18_or_over_election = (0)) predict(xb) post level(76) 
est store below_thresh_18_xb

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_18_election=(0(5)730)  age_18_or_over_election = (1)) predict(xb) post level(76) 
est store above_thresh_18_xb

coefplot 	(above_thresh_18_xb, recast(line) lcolor(black*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rarea) lwidth(none) fcolor(black) )) /// 			
			(below_thresh_18_xb, recast(line) lcolor(black) lpattern(solid) lwidth(medium)  ciopts(recast(rarea) lwidth(none) fcolor(black*.5) )) /// 
			, 	at	level(76)  ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Latent Satisfaction with Democracy", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(5.5) ysize(5) legend(off) ///
				ylabel(-1(1)3)  yscale(range(-1.05 3.05))  ///
				graphregion(margin(medsmall))  ///
				b1title("Days From Age 18 on Election Day") ///
				addplot(pci -1.02 0  3.02 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) 



**************
**************
*Figure SM6
**************
**************
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=(-731(10)-1) age_18_or_over_election = (0)) predict(outcome(1)) post level(76) 
estimates store below_thresh_18_cat_1

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_18_election=(0(10)730)  age_18_or_over_election = (1)) predict(outcome(1)) post level(76) 
estimates store above_thresh_18_cat_1

coefplot 	(above_thresh_18_cat_1, recast(line) lcolor(black*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(black) )) /// 			
			(below_thresh_18_cat_1, recast(line) lcolor(black) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(black*.5) )) /// 
			, 	at	level(76)  ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Very Dissatisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_1, replace)


ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=(-731(10)-1) age_18_or_over_election = (0)) predict(outcome(2)) post level(76) 
estimates store below_thresh_18_cat_2

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_18_election=(0(10)730)  age_18_or_over_election = (1)) predict(outcome(2)) post level(76) 
estimates store above_thresh_18_cat_2

coefplot 	(above_thresh_18_cat_2, recast(line) lcolor(red*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(red) )) /// 			
			(below_thresh_18_cat_2, recast(line) lcolor(red) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(red*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Dissatisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_2, replace)


ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=(-731(10)-1) age_18_or_over_election = (0)) predict(outcome(3)) post level(76) 
estimates store below_thresh_18_cat_3

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_18_election=(0(10)730)  age_18_or_over_election = (1)) predict(outcome(3)) post level(76) 
estimates store above_thresh_18_cat_3


coefplot 	(above_thresh_18_cat_3, recast(line) lcolor(blue*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(blue) )) /// 			
			(below_thresh_18_cat_3, recast(line) lcolor(blue) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(blue*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Satisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_3, replace)
				
ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=(-731(10)-1) age_18_or_over_election = (0)) predict(outcome(4)) post level(76) 
estimates store below_thresh_18_cat_4

ologit dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_18_election=(0(10)730)  age_18_or_over_election = (1)) predict(outcome(4)) post level(76) 
estimates store above_thresh_18_cat_4

coefplot 	(above_thresh_18_cat_4, recast(line) lcolor(green*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(green) )) /// 			
			(below_thresh_18_cat_4, recast(line) lcolor(green) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(green*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Very Satisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_4, replace)

*combine graphs
graph 	combine	///
			cat_1		///
			cat_2		///
			cat_3		///
			cat_4		///
	, 		ysize(5)	rows(2) ycommon graphregion(margin(zero)) scheme(s1mono)  scale(1)  ///
				b1title("           Days From Age 18 on Election Day", size(small)) 
				

**************
**************
*Figure SM7
**************
**************
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=(-1091(10)-1) age_70_or_over_election = (0)) predict(xb) post level(76) 
est store below_thresh_70_xb

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_70_election=(0(10)1090)  age_70_or_over_election = (1)) predict(xb) post level(76) 
est store above_thresh_70_xb

coefplot 	(below_thresh_70_xb, recast(line) lcolor(black*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rarea) lwidth(none) fcolor(black) )) /// 			
			(above_thresh_70_xb, recast(line) lcolor(black) lpattern(solid) lwidth(medium)  ciopts(recast(rarea) lwidth(none) fcolor(black*.5) )) /// 
			, 	at	level(76)  ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Latent Satisfaction with Democracy", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(5.5) ysize(5) legend(off) ///
				ylabel(-1(1)3)  yscale(range(-1.05 3.05))  ///
				graphregion(margin(medsmall))  ///
				b1title("Days From Age 70 on Election Day") ///
				addplot(pci -1.02 0  3.02 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) 




**************
**************
*Figure SM8
**************
**************
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=(-1091(10)-1) age_70_or_over_election = (0)) predict(outcome(1)) post level(76) 
estimates store below_thresh_70_cat_1

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_70_election=(0(10)1090)  age_70_or_over_election = (1)) predict(outcome(1)) post level(76) 
estimates store above_thresh_70_cat_1

coefplot 	(below_thresh_70_cat_1, recast(line) lcolor(black*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(black) )) /// 			
			(above_thresh_70_cat_1, recast(line) lcolor(black) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(black*.5) )) /// 
			, 	at	level(76)  ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Very Dissatisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_1, replace)


ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=(-1091(10)-1) age_70_or_over_election = (0)) predict(outcome(2)) post level(76) 
estimates store below_thresh_70_cat_2

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_70_election=(0(10)1090)  age_70_or_over_election = (1)) predict(outcome(2)) post level(76) 
estimates store above_thresh_70_cat_2

coefplot 	(below_thresh_70_cat_2, recast(line) lcolor(red*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(red) )) /// 			
			(above_thresh_70_cat_2, recast(line) lcolor(red) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(red*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Dissatisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_2, replace)


ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=(-1091(10)-1) age_70_or_over_election = (0)) predict(outcome(3)) post level(76) 
estimates store below_thresh_70_cat_3

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_70_election=(0(10)1090)  age_70_or_over_election = (1)) predict(outcome(3)) post level(76) 
estimates store above_thresh_70_cat_3

coefplot 	(below_thresh_70_cat_3, recast(line) lcolor(blue*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(blue) )) /// 			
			(above_thresh_70_cat_3, recast(line) lcolor(blue) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(blue*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Satisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_3, replace)
				
ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=(-1091(10)-1) age_70_or_over_election = (0)) predict(outcome(4)) post level(76) 
estimates store below_thresh_70_cat_4

ologit dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  dydx(voted_Fernandez) at(days_over_70_election=(0(10)1090)  age_70_or_over_election = (1)) predict(outcome(4)) post level(76) 
estimates store above_thresh_70_cat_4

coefplot 	(below_thresh_70_cat_4, recast(line) lcolor(green*1.5) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(green) )) /// 			
			(above_thresh_70_cat_4, recast(line) lcolor(green) lpattern(solid) lwidth(medium)  ciopts(recast(rspike) lwidth(vthin) lcolor(green*.5) )) /// 
			, 	at	level(76)   ///
				xline(0, lcolor(black*2) lwidth(medthick) lpattern(solid))  ///
				ytitle("Association Between Winning" "and Pr(Very Satisfied)", size(medium)) ///
				legend(off)  graphregion(color(white)) ///
				scheme(s1color) xsize(7) ysize(5) legend(off) ///
				graphregion(margin(medsmall)) ///
				ylabel(-.4(0.2)0.4)  yscale(range(-.45 .45))  ///
				addplot(pci -.42 0  .42 0, lcolor(black*2) lwidth(medthick) lpattern(solid)) ///
				name(cat_4, replace)

*combine graphs
graph 	combine	///
			cat_1		///
			cat_2		///
			cat_3		///
			cat_4		///
	, 		ysize(5)	rows(2) ycommon graphregion(margin(zero)) scheme(s1mono)  scale(1)  ///
				b1title("           Days From Age 70 on Election Day", size(small)) 
				

				


**************
**************
*Figure SM9
**************
**************
reg dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_18_election=0 age_18_or_over_election=(0 1)) predict(xb) post level(90) 

coefplot ///
		( , offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Satisfaction with Democracy" " ") ///
	legend(off) 	///			 
	coeflabels( 1._at  = 	`" "Just under 18" "(No Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 18" "(Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-0.5(0.5)1.5)  ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(4.8)  ysize(7) scale(1.31) level(90) format(%9.1f)

	
	
**************
**************
*Figure SM10
**************
**************
reg dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins, dydx(voted_Fernandez) at(days_over_70_election=0 age_70_or_over_election=(0 1)) predict(xb) post level(90) 

coefplot ///
		( , offset(0) recast(scatter) mcolor(black) msize(medsmall) ciopts(lpattern(solid) lcolor(black))) ///
	,  scheme(s1color) vertical ///
	ytitle("Association Between Winning" "and Satisfaction with Democracy" " ") ///
	legend(off) 	///			 
	coeflabels( 1._at  = 	`" "Just under 70" "(No Compulsory Voting)" "'  ///
				2._at  = 	`" "Just over 70" "(Compulsory Voting)" "' ) ///
	graphregion(margin(small)) ///
	ylabel(-0.5(0.5)1.5)  ///
	xlabel(, labsize(small)) ///
	yline(0,   lcolor(gs3) lwidth(thin) lpattern(dash)) ///
	xline(1.5, lcolor(gs3) lwidth(medium) lpattern(solid)) ///
	xsize(4.8)  ysize(7) scale(1.31) level(90) format(%9.1f)


**************
**************
*Evidence for Claim Made in the Text: "... winning has a bigger positive association with satisfaction when voting is voluntary rather than obligatory... this difference has a two-sided p-value of 0.039 for the younger age group and a two-sided p-value of 0.400 for the older age group"
**************
**************	
reg dem_sat  i.age_18_or_over_election##c.days_over_18_election##i.voted_Fernandez    educ income female ideo if samp_18 == 1, robust
margins,  at(days_over_18_election=0 age_18_or_over_election=(0 1) voted_Fernandez = (0 1)) predict(xb) post level(90) coeflegend
test (_b[2._at] - _b[1bn._at]) = (_b[4._at] - _b[3._at]) //*same as p-value on the interaction between winning and exposure to compulsory voting

reg dem_sat  i.age_70_or_over_election##c.days_over_70_election##i.voted_Fernandez    educ income female ideo if samp_70 == 1, robust
margins,  at(days_over_70_election=0 age_70_or_over=(0 1) voted_Fernandez = (0 1)) predict(xb) post level(90) coeflegend
test (_b[2._at] - _b[1bn._at]) = (_b[4._at] - _b[3._at]) //*same as p-value on the interaction between winning and exposure to compulsory voting


	

***                .     _,
***                |`\__/ /
***                \  . .(
***                 | __T|     Thanks for replicating!
***                /   |
***   _.---======='    |
***  //               {}
*** `|      ,   ,     {}
***  \      /___;    ,'
***   ) ,-;`    `\  //
***  | / (        ;||
***  |`\\         |||
***  || \\        |||
***  )\  )\       )||
***  `"  `"       `""

